package com.aaa.ddd.service;

import com.aaa.pojo.Dept;
import com.aaa.pojo.Page;
import com.aaa.pojo.ResultBean;
import com.aaa.ddd.dao.DeptDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptSeriveimpl implements DeptService{
    @Autowired
    private DeptDao deptDao;
    @Override
    public  ResultBean findAll(Page page,Dept dept){
        PageHelper.startPage(page.getPage(),page.getLimit());
        List<Dept> list = deptDao.findAll(dept);
        PageInfo<Dept> pageInfo =new PageInfo<Dept>(list);
        return new ResultBean(0,"查询成功",pageInfo.getTotal(),pageInfo.getList());
    }
    @Override
    public  Integer deletept(Integer dept_id){

        return deptDao.deletept(dept_id);
    }

    @Override
    public int updarept(Dept dept) {

        return deptDao.updatept(dept);
    }

    @Override
    public int savept(Dept dept) {
        System.out.println(dept);
        return deptDao.savept(dept);
    }

    @Override
    public int deletespt(@Param("dept_id") int[] dept_id) {
        return deptDao.deletespt(dept_id);
    }


}
